-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rock - lin #52
base: master
Are you sure you want to change the base?
Rock - lin #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done Lin, you hit the learning goals here. Well done. I did leave some minor comments. Take a look and let me know what questions you have.
# Time Complexity: O(log(n))*assumes all balanced tree | ||
# Space Complexity: O(1) | ||
def add(self, key, value=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However due to the recursive call stack this is O(log n) for space complexity (if the tree is balanced and O(n) otherwise).
# Time Complexity: O(log(n)) | ||
# Space Complexity: O(1) | ||
def find(self, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Similar issues with space complexity.
# Time Complexity: O(logn) | ||
# Space Complexity: O(n) | ||
def inorder(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Since you hit each node and make a list the of all the nodes in the tree the time and space complexity is O(n)
# Time Complexity: O(logn) | ||
# Space Complexity: O(n) | ||
def preorder(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Similar issues to time/space complexity
# Time Complexity: O(logn) | ||
# Space Complexity: O(n) | ||
def postorder(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Similar issues to time/space complexity
# Time Complexity: O(logn) | ||
# Space Complexity: O(1) | ||
def height(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However the space complexity is O(log n) due to the recursive call stack.
No description provided.